<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Socket</title>
</head>
<body>
  <h1>Socket demo</h1>
  <script>
    let socket = new WebSocket("ws://localhost:3000");

    socket.onopen = function() {
      socket.send('浏览器发出的内容');
    }

    socket.onmessage = function(e) {
      console.log(e.data);
    }

  </script>
</body>
</html>